<template>
  <div class="home">
    <div class="card-container">
      <div class="card-item">
        <div class="card-item-left">
          <i class="el-icon-user-solid"></i>
        </div>
        <div class="card-item-right">
          <div class="card-item-right-title">用户</div>
          <div class="card-item-right-value">22,000</div>
        </div>
      </div>
      <div class="card-item">
        <div class="card-item-left">
          <i class="el-icon-s-goods"></i>
        </div>
        <div class="card-item-right">
          <div class="card-item-right-title">商品</div>
          <div class="card-item-right-value">92,000</div>
        </div>
      </div>
      <div class="card-item">
        <div class="card-item-left">
          <i class="el-icon-s-promotion"></i>
        </div>
        <div class="card-item-right">
          <div class="card-item-right-title">分享数</div>
          <div class="card-item-right-value">822,000</div>
        </div>
      </div>
      <div class="card-item">
        <div class="card-item-left">
          <i class="el-icon-s-data"></i>
        </div>
        <div class="card-item-right">
          <div class="card-item-right-title">下载数</div>
          <div class="card-item-right-value">152,000</div>
        </div>
      </div>
    </div>
    <div class="chart-wrap">
      <div class="chart-title">销售金额</div>
      <Lines ref="spend" />
    </div>
    <div class="chart-wrap">
      <div class="chart-title">下载数</div>
      <Lines ref="consume" />
    </div>
  </div>
</template>

<script>
// import E from 'wangeditor'
import axios from 'axios';
import DataLines from './echart/List.vue';
import Lines from '../components/echart/Lines.vue';
import { spendData, consumeData } from '../models/fake-data';

export default {
  name: 'home',
  components: {
    Lines,
  },
  created() {},
  mounted() {
    this.query();
  },
  watch: {},
  data() {
    return {};
  },
  methods: {
    query() {
      this.spendTrend();
      this.consumeDetailList();
    },
    async spendTrend() {
      let date = spendData && spendData.map((item) => item.date);
      let amount = spendData && spendData.map((item) => item.amount);
      this.$refs.spend && this.$refs.spend.init(date, amount);
    },
    async consumeDetailList() {
      let date = consumeData && consumeData.map((item) => item.date);
      let amount = consumeData && consumeData.map((item) => item.amount);
      this.$refs.consume && this.$refs.consume.init(date, amount);
    },
  },
};
</script>
<style lang="scss">
.home {
  // h1 {
  //   font-size: 2em;
  //   padding: 20px;
  //   margin: 0;
  // }
  .card-container {
    display: flex;

    .card-item {
      flex: 1;
      margin-right: 20px;
      background: #fff;
      display: flex;

      &:last-child {
        margin-right: 0;
      }

      .card-item-left {
        margin: 14px 0 0 14px;
        padding: 16px;

        i {
          font-size: 40px;
        }

        .el-icon-user-solid {
          color: $blue;
        }

        .el-icon-s-goods {
          color: $orange;
        }

        .el-icon-s-promotion {
          color: $green;
        }

        .el-icon-s-data {
          color: $errorRed;
        }
      }

      .card-item-right {
        font-weight: 700;
        margin: 20px;

        .card-item-right-title {
          line-height: 18px;
          color: rgba(0, 0, 0, 0.45);
          font-size: 16px;
          margin-bottom: 12px;
        }

        .card-item-right-value {
          font-size: 20px;
        }
      }
    }
  }

  .chart-wrap {
    margin-top: 20px;
    background: #fff;

    .chart-title {
      font-size: 16px;
      margin-bottom: 16px;
      padding: 16px;
    }
  }
}
</style>
